//package jp.sourceforge.talisman.mds.cluster;
//
///*
// * $Id: ParallelHardCMeanMethodTest.java,v 1.1 2009/09/12 05:06:00 weiwei Exp $
// */
//
//import jp.sourceforge.talisman.mds.Item;
//import jp.sourceforge.talisman.mds.distance.SquaredEuclideanItemDistanceCalculator;
//
//import org.junit.Assert;
//import org.junit.Before;
//import org.junit.Test;
//
///**
// * 
// * @author Haruaki Tamada
// * @version $Revision: 1.1 $ 
// */
//public class ParallelHardCMeanMethodTest{
//    private Item[] items;
//
//    @Before
//    public void initialize(){
//        items = new Item[5];
//
//        items[0] = new Item("item1", new double[] { 3, 4, });
//        items[1] = new Item("item2", new double[] { 1, 1, });
//        items[2] = new Item("item3", new double[] { 2, 1, });
//        items[3] = new Item("item4", new double[] { 1, 2, });
//        items[4] = new Item("item5", new double[] { 4, 4, });
//    }
//
//    @Test
//    public void testAbstractClusteringMethod(){
//        ClusteringMethod method1 = new ParallelHardCMeanMethod(new NonHierarchicalClusteringParameter(2));
//        Assert.assertNull(method1.getDistanceCalculator());
//            
//
//        ClusteringMethod method2 = new ParallelHardCMeanMethod(
//            new NonHierarchicalClusteringParameter(2, new SquaredEuclideanItemDistanceCalculator())
//        );
//        Assert.assertTrue(method2.getDistanceCalculator() instanceof SquaredEuclideanItemDistanceCalculator);
//        
//    }
//
//    @Test
//    public void testBasic() throws Exception{
//        ClusteringMethod method = new ParallelHardCMeanMethod(
//            new NonHierarchicalClusteringParameter(2, new SquaredEuclideanItemDistanceCalculator())
//        );
//        Cluster[] clusters = method.clustering(items);
//        Assert.assertEquals(2, clusters.length);
//        Assert.assertEquals(2, clusters[0].getSize());
//        Assert.assertEquals(3, clusters[1].getSize());
//
//        Assert.assertTrue(clusters[0].isContain(items[0]));
//        Assert.assertTrue(clusters[0].isContain(items[4]));
//
//        Assert.assertTrue(clusters[1].isContain(items[1]));
//        Assert.assertTrue(clusters[1].isContain(items[2]));
//        Assert.assertTrue(clusters[1].isContain(items[3]));
//    }
//
//    @Test
//    public void testBasic2() throws Exception{
//        ClusteringParameter param = new NonHierarchicalClusteringParameter(2, new SquaredEuclideanItemDistanceCalculator());
//        ClusteringMethod method = new ParallelHardCMeanMethod(param);
//
//        Cluster[] clusters = method.clustering(items);
//        Assert.assertEquals(2, clusters.length);
//        Assert.assertEquals(2, clusters[0].getSize());
//        Assert.assertEquals(3, clusters[1].getSize());
//
//        Assert.assertTrue(clusters[0].isContain(items[0]));
//        Assert.assertTrue(clusters[0].isContain(items[4]));
//
//        Assert.assertTrue(clusters[1].isContain(items[1]));
//        Assert.assertTrue(clusters[1].isContain(items[2]));
//        Assert.assertTrue(clusters[1].isContain(items[3]));
//    }
//
//    @Test(expected=NullPointerException.class)
//    public void testNullParameter() throws Exception{
//        new ParallelHardCMeanMethod(null);
//    }
//
//    /**
//     * parameter type is mismatched.
//     */
//    @Test(expected=ParameterTypeMismatchException.class)
//    public void testParamTypeMismatchException() throws Exception{
//        ClusteringMethod method = new ParallelHardCMeanMethod(new DummyClusteringParameter());
//        method.clustering(items);
//    }
//
//    /**
//     * distance calculator is missing.
//     */
//    @Test(expected=InvalidParameterException.class)
//    public void testCalculatorNotFoundException() throws Exception{
//        ClusteringMethod method = new ParallelHardCMeanMethod(new NonHierarchicalClusteringParameter(2));
//        method.clustering(items);
//    }
//
//    /**
//     * The number of cluster is too big.
//     */
//    @Test(expected=InvalidParameterException.class)
//    public void testParameterException() throws Exception{
//        ClusteringMethod method = new ParallelHardCMeanMethod(new NonHierarchicalClusteringParameter(10));
//        method.clustering(items);
//    }
//}
